/*
 * Copyright 2009 Jiwei Xu (http://www.xujiwei.com)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

provide("Objects.CurveObj");

require("Objects.FigureObj");

CurveObj = Class(FigureObj, {
    Initialize : function() {
        this.Base();

        this.Handles = [];
    },

    Draw : function(ctx) {
        this.SetStyles(ctx);

        ctx.beginPath();
        var handles = this.Handles;
        ctx.moveTo(handles[0].X, handles[0].Y);
        
        for (var i = 2; i < handles.length; i+=2) {
            ctx.quadraticCurveTo(handles[i-1].X, handles[i-1].Y, handles[i].X, handles[i].Y);
        }

        if (this.IsFill) {
            ctx.closePath();
            ctx.fill();
        }
        ctx.stroke();
    }
});